package com.od.controller;

import com.od.entity.Seeker;
import com.od.service.SeekerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("seeker")
@CrossOrigin
public class SeekerController {
    @Autowired
    private SeekerService seekerService;

    @RequestMapping("allSeeker")
    @ResponseBody
    public List<Seeker> getAllSeeker() {
        return seekerService.getAllSeeker();
    }

    @RequestMapping("getSeekerByTel")
    @ResponseBody
    public Seeker getSeekerByTel(String tel) {
        return seekerService.getSeekerByTel(tel);
    }

    @RequestMapping("getSeekerById")
    @ResponseBody
    public List<Seeker> getSeekerById(String seekerId) {
        return seekerService.getSeekerById(seekerId);
    }

    @RequestMapping("getIdByTel")
    @ResponseBody
    public int getIdByTel(String tel) {
        return seekerService.getIdByTel(tel);
    }

    @PostMapping("addSeeker")
    @ResponseBody
    public int addSeeker(@RequestBody  Seeker seeker) {
        System.out.println(seeker.getTel());
        return  seekerService.addSeeker(seeker);
    }

    @RequestMapping("updateSeekerById")
    @ResponseBody
    public int updateSeekerById(@RequestBody Seeker seeker) {
        System.out.println(seeker);
        return seekerService.updateSeekerById(seeker);
    }

}
